#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Multi_Menu.h"
#include "Key.h"

uint8_t Key_Num=0;

uchar func_index = 0; 
uchar last_index = 127; 

void (*current_operation_index)();


int main(void)
{
	OLED_Init();
	Key_Init();
	
	while (1)
	{
		Key_Num=Key_GetNum();
			if (Key_Num == 1)
		{
			func_index = table[func_index].up;
		}
		if (Key_Num == 2)
		{
			func_index = table[func_index].enter;
		}
		if (Key_Num == 3)
		{
			func_index = table[func_index].down; 
		}
		
		if (func_index != last_index)
			{
				current_operation_index = table[func_index].current_operation;
				
				OLED_Clear(); 
				(*current_operation_index)();
				OLED_Update();
		
				last_index = func_index;
			}
	}
}
